var editor;
layui.use(['form','laydate'], function () {
    var form = layui.form;
    var laydate = layui.laydate;
    laydate.render({
        elem: '#create_time',
        type: 'datetime',
        trigger: "click",
        btns: ["confirm", "now"]
    });
    form.on('submit(btn_add)', function (data) {
        ajaxAdd(data.field);
        return false;
    });
});

function ajaxAdd(data) {
    var content = editor.html();
    if (content == "") {
        layer.alert("请输入公告内容");
        return;
    }
    data["create_time"] = strToLongTime(data["create_time"]);
    data["content"] = content;
    var url = "/notice/update";
    var subIndex=showLoading('数据提交中...');
    postAjax(url, data, function (res) {
        layer.close(subIndex);
        if (res["code"] == 0) {
            layer.msg(res["msg"]);
        } else {
            layer.msg(res["msg"]);
        }

    }, function () {
        layer.close(subIndex);
        layer.msg("提交发生异常");
    });
}
$(function () {
    editor = initEditor("noticeContent");
});